
import { ref } from 'vue'

export const useUpload = () => {
    const imageList = ref([])

    const handleUpload = (info) => {
      let resFileList = [...info.fileList]

      if (resFileList.length) {
        resFileList.map((file, index) => {
          if (file.response) {
            if (file.response.code == 1000) {
              file.url = file.response.data.fileUrl
            } else {
              message.warning(file.response.msg)
              resFileList.splice(index, 1)
            }
          }
        })
      }

      imageList.value = resFileList;
    }

    return { imageList, handleUpload }
}